// This function will show and hide question details and comments.
// It will not support older browsers and so pages should be coded
// appropriately.
function showHide(e) {
	if(!supportedBrowser(e)) return true;

	element = getElement(e);
	//Get the menu object for the event
	obj = document.getElementById("q"+element.id);

	visible = (obj.style.display == "table-row");

	if(visible) {
		obj.style.display = "none";
	} else {
		obj.style.display = "table-row";
	}
	// Returning false will prevent the
	// link from being followed.
	return false;
}

function expand(e) {
	if(!supportedBrowser(e)) return true;
	
	element = getElement(e);

	return showHide(e);
}

function getComments(e) {
	//ajaxFunction(e);

	return showHide(e);
}

// This section assigns the function, expand, to
// the element that has a class of 'detail' and
// function, showHide, to elements of 'comment'
// This has to be done after the Element has be created
// that is you must include this file after these elements
// have been defined.
elements = getElementsByClassName("expand");
for(var i in elements)  {
	elements[i].onclick = expand;
}

elements = getElementsByClassName("comment");
for(var i in elements)  {
	elements[i].onclick = getComments;
}

function ajaxFunction(e) {
	var xmlHttp;
	try {
		xmlHttp = new XMLHttpRequest();
	} catch (e) {
		try {
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
				return false;
			}
		}
	}

	element = document.getElementById("q"+getElement(e).id);

	xmlHttp.onreadystatechange = function() {
		if(xmlHttp.readyState == 4) {
			// Get data from servers response
			// data returned in xmlHttp.responseText;
			element.innerHTML = "";
			element.innerHTML = xmlHttp.responseText;
		}
	}

if(element.innerHTML=="") {
	xmlHttp.open("GET","ajax.php",true);
	xmlHttp.send(null);
}
}
